﻿using Sustainalytics.Entities.SustainableProducts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sustainalytics.Entities.ProductInvolvement
{
    public class PICompanyInternal : IEntity, IHasUniverseIds
    {
        public Guid Id { get; set; }
        public List<int> UniverseIds { get; set; }
        public string CompanyName { get; set; }
        public Dictionary <(string, string), ProductInvolvementFrameworkInternal> Indicators { get; set; }
        public string Country { get; set; }
        public string Industry { get; set; }
        public string IndustryId { get; set; }
        public string PeerGroupName { get; set; }
        public int CompanyId { get; set; }
        public string Exchange { get; set; }
        public string Ticker { get; set; }
        public string CompanyNameLowerCase { get; set; }
        public double? MarketCap { get; set; }
        public double? Employees { get; set; }
        public string CompanyNameSafeUrl { get; set; }
        public string Currency { get; set; }

        public ProductInvolvementData ToPICompanyAssessment()
        {
            return new ProductInvolvementData
            {
                Id = Id,
                CompanyName = CompanyName,
                Country = Country,
                Industry = Industry,
                IndustryId = IndustryId,
                PeerGroupName = PeerGroupName,
                CompanyId = CompanyId,
                Exchange = Exchange,
                Ticker = Ticker,
                CompanyNameLowerCase = CompanyNameLowerCase,
                MarketCap = MarketCap,
                Employees = Employees,
                CompanyNameSafeUrl = CompanyNameSafeUrl,
                Indicators = Indicators.Select(x => x.Value).ToList().ConvertAll(x => x.ToPIIndicatorAssessment()).Where(x => x != null).ToList(),
            };
        }

        public SustainableProductsData ToPICompanySolution()
        {
            return new SustainableProductsData
            {
                Id = Id,
                CompanyName = CompanyName,
                Country = Country,
                Industry = Industry,
                IndustryId = IndustryId,
                PeerGroupName = PeerGroupName,
                CompanyId = CompanyId,
                Exchange = Exchange,
                Ticker = Ticker,
                CompanyNameLowerCase = CompanyNameLowerCase,
                MarketCap = MarketCap,
                Employees = Employees,
                CompanyNameSafeUrl = CompanyNameSafeUrl,
                Currency = Currency,
                Indicators = Indicators.Select(x => x.Value).ToList().ConvertAll(x => x.ToPIIndicatorSolution()).Where(x => x != null).ToList()
            };
        }
    }
}
